﻿using System;
using System.Web.UI.HtmlControls;
using BaseEntities;
using BussinessLogic;

namespace ATMSystem_G5_HaUI.UC3
{
    public partial class CheckBalance1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                var checkBalanceLogic = new CheckBalanceLogic();

                if (Session["CardNo"] != null)
                {
                    string cardNo = Session["CardNo"].ToString();
                    var account = new Account();
                    account = checkBalanceLogic.GetAccountCb(cardNo);

                    if (account != null)
                    {
                        pnCb01.Visible = true;
                        pnCb02.Visible = false;
                        lbAccountNo.Text = account.AccountID.ToString();
                        lbCardNo.Text = cardNo;
                        lbBalance.Text = account.Balance.ToString();
                    }
                    else
                    {
                        pnCb01.Visible = false;
                        pnCb02.Visible = true;
                    }
                }
                else
                {
                    pnCb01.Visible = false;
                    pnCb02.Visible = true;                                            
                }
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            if (pnCb01.Visible)
            {
                Response.Redirect("~/Home.aspx");                          
            }
        }

        protected void btnEnter_Click(object sender, EventArgs e)
        {
            if (pnCb01.Visible)
            {
                Response.Redirect("~/Home.aspx");
            }      
        }
    }
}